﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OABackground.Services;

namespace SchoolOA.Controllers
{
    public class ZJCController : Controller
    {
        protected IndexService indexservice = new IndexService();
        protected ZhenJiaoService zhenJiaoService = new ZhenJiaoService();
        
        public IActionResult Index()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            return View();
        }

        public IActionResult ShowPunish()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            return View();
        }
        public IActionResult CommitPlan()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            ViewData["teacherID"] = name;
            return View();
        }
        public IActionResult SubmitPlan ()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            return View();
        }
        public IActionResult DocManager()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            return View();
        }
        public IActionResult ConventionManager()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            return View();
        }

        public IActionResult SearchTeacher()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            return View();
        }
        public IActionResult HandlePunish(int id)
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            ViewData["HPID"] = id;
            return View();
        }
        public IActionResult HandleAward(int id)
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            ViewData["HAID"] = id;
            return View();
        }
        public IActionResult HandleMaterial(int id)
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            ViewData["HMID"] = id;
            return View();
        }

        public IActionResult HandleConvention(int id)
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("zjc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherName"] = zhenJiaoService.QueryTeaherById(name).Tname;
            ViewData["HCID"] = id;
            return View();
        }
    }
}
